package com.asj.house.controller;

import com.asj.house.client.HouseRoomDetailClient;
import com.asj.house.domain.HouseRoomDetail;
import com.asj.house.returns.RespEntity;
import com.asj.house.returns.RespTable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 房源详细信息管理 前端控制器
 * </p>
 *
 * @author asj
 * @since 2021-02-03
 */
@RestController
@RequestMapping("/house-room-detail")
@Slf4j
@Api(value = "房源详细信息相关接口", tags = "房源详细信息相关接口")
public class HouseRoomDetailController {

    @Resource
    private HouseRoomDetailClient houseRoomDetailClient;

    @ApiOperation(value = "房源详细信息列表")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true)
    })
    public RespTable listHouseRoomDetail(@RequestParam(value = "page", required = true) Integer page,
                                         @RequestParam(value = "limit", required = true) Integer limit) {
        RespTable respTable = houseRoomDetailClient.listHouseRoomDetail(page, limit);
        return respTable;
    }

    @GetMapping("/search")
    @ApiOperation(value = "搜索房源详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "name", value = "小区名称", required = true)
    })
    public RespTable searchHouseRoomDetail(@RequestParam(value = "page", required = true) Integer page,
                                           @RequestParam(value = "limit", required = true) Integer limit,
                                           @RequestParam(value = "name", required = true) String name) {
        RespTable respTable = houseRoomDetailClient.searchHouseRoomDetail(page, limit, name);
        return respTable;
    }

    @PutMapping("/update")
    @ApiOperation(value = "编辑房源详细信息")
    public RespEntity updateHouseRoomDetail(HouseRoomDetail houseRoomDetail) {
        RespEntity respEntity = houseRoomDetailClient.updateHouseRoomDetail(houseRoomDetail);
        return respEntity;
    }

    @GetMapping("/chinaMap")
    @ApiOperation(value = "中国地图")
    public RespEntity chinaMap() {
        RespEntity respEntity = houseRoomDetailClient.chinaMap();
        return respEntity;
    }

    @GetMapping("/provinceMap")
    @ApiOperation(value = "省份地图")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "province", value = "省份名称", required = true)
    })
    public RespEntity province(@RequestParam(value = "province", required = true) String province) {
        RespEntity respEntity = houseRoomDetailClient.provinceMap(province);
        return respEntity;
    }
}
